package com.banesco.precargadepositos.interfaz.componentes;

import net.rim.device.api.system.Display;
import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.Font;
import net.rim.device.api.ui.Graphics;
import net.rim.device.api.ui.Manager;

public class GestorTablaBanesco extends Manager {

	protected GestorTablaBanesco(){
		super(0);
	
	}
	
	// Causes the fields within this row manager to be layed out then
    // painted.
    public void drawRow(Graphics g, int x, int y, int width, int height)
    {
        // Arrange the cell fields within this row manager.
        layout(width, height);

        // Place this row manager within its enclosing list.
        setPosition(x, y);

        // Apply a translating/clipping transformation to the graphics
        // context so that this row paints in the right area.
        g.pushRegion(getExtent());

        // Paint this manager's controlled fields.
        subpaint(g);
        
        g.setColor(0x00CACACA);
        g.drawLine(0, 0, getPreferredWidth(), 0);
        g.drawLine(10, 0, 10, getPreferredHeight());

        // Restore the graphics context.
        g.popContext();
    }

	protected void sublayout(int width, int height) {
        // set the size and position of each field.
        int fontHeight = Font.getDefault().getHeight();
        int preferredWidth = getPreferredWidth();
        
        // start with the Bitmap Field of the priority icon
        Field field = getField(0);
        layoutChild(field, 10, 40);
        setPositionChild(field, 0, 0);
        
        // set the task name label field 
        field = getField(1);
        layoutChild(field, preferredWidth - 16, fontHeight+1);
        setPositionChild(field, 16, 3);
                    
        // set the list name label field 
        field = getField(2);
        layoutChild(field, 150, fontHeight+1);
        setPositionChild(field, 16, fontHeight+6);
        
        // set the due time name label field 
        field = getField(3);
        layoutChild(field, 150, fontHeight+1);
        setPositionChild(field, preferredWidth - 152, fontHeight+6);

        setExtent(preferredWidth, getPreferredHeight());
    }
	

    // The preferred width of a row is defined by the list renderer.
    public int getPreferredWidth()
    {
        return Display.getWidth();
    }

    // The preferred height of a row is the "row height" as defined in the
    // enclosing list.
    public int getPreferredHeight()
    {
        return getContentHeight();
    }

}
